package com.bigdatan.b2c.controller.glass;

import com.bigdatan.b2c.controller.AbstractController;
import com.bigdatan.b2c.controller.glass.enums.DotCountTypeEnum;
import com.bigdatan.b2c.service.glass.ICountService;
import constant.SystemCode;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import util.JsonResponse;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by shangdong on 17/5/14.
 */
@RestController
@RequestMapping("/api")
public class GlassDotController extends AbstractController {

    @Resource
    private ICountService countService;

    @RequestMapping(method = {RequestMethod.POST, RequestMethod.GET},value = "/count")
    public JsonResponse<Boolean> getGlassByCategoryID(Integer countType,HttpServletRequest request){
        JsonResponse<Boolean> res = new JsonResponse<>();
        DotCountTypeEnum enumByType = DotCountTypeEnum.getEnumByType(countType);
        if (enumByType == null){
            res.setRes(SystemCode.ILLEGAL_ARGUMENT);
            res.setObj(false);
            return res;
        }
        boolean b = countService.addDotCount(enumByType);
        res.setRes(SystemCode.SUCCESS);
        res.setObj(true);
        return res;
    }
}
